package com.atjava.webspider.model;

import java.util.List;

import com.atjava.jox.annotation.ClassProps;
import com.atjava.jox.annotation.FieldProps;
import com.atjava.jox.annotation.FieldProps.ElementType;
import com.atjava.webspider.logic.Named;

@ClassProps(alias="site")
public class Site implements Named{
	
	@FieldProps
	private String name;
	
	@FieldProps
	private String charset;

	@FieldProps(type=ElementType.ELEMENT)
	private List<Replace> replaces;
	
	@FieldProps(type=ElementType.ELEMENT)
	private List<Page> pages;
	
	public String getPageNames(){
		StringBuffer bf = new StringBuffer();
		for(Page p : pages){
			bf.append(",");
			bf.append(p.getName());
		}
		return bf.toString().replaceFirst(",", "");
	}
	
	public int getReplaceNum(){
		return replaces == null ? 0 : replaces.size();
	}
	
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public List<Replace> getReplaces() {
		return replaces;
	}

	public void setReplaces(List<Replace> replaces) {
		this.replaces = replaces;
	}

	public List<Page> getPages() {
		return pages;
	}

	public void setPages(List<Page> pages) {
		this.pages = pages;
	}

	public String getCharset() {
		return charset;
	}

	public void setCharset(String charset) {
		this.charset = charset;
	}
}
